﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example15.aspx.cs" Inherits="Chapter28.Example15" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 28-15 使用 innerHTML 和 outerHTML 属性</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style>
        table {
            border: solid thin black;
            border-collapse: collapse;
            margin: 5px 2px;
            float: left;
        }

        td {
            padding: 4px 5px;
        }

        p {
            clear: left;
        }
    </style>
</head>
<body>
    <table border="1">
        <thead>
            <tr>
                <th>Fruit</th>
                <th>Color</th>
            </tr>
        </thead>
        <tbody>
            <tr id="applerow">
                <td>Plum</td>
                <td>Purple</td>
            </tr>
        </tbody>
    </table>
    <textarea rows="3" id="results"></textarea>
    <p>
        <button id="inner">Inner HTML</button>
        <button id="outer">Outer HTML</button>
    </p>
    <script>
        var results = document.getElementById("results");
        var row = document.getElementById("applerow");

        document.getElementById("inner").onclick = function () {
            results.innerHTML = row.innerHTML;
        };

        document.getElementById("outer").onclick = function () {
            results.innerHTML = row.outerHTML;
        };
    </script>
</body>
</html>
